From 4b850bd91f4127621c7cca612983578a741c249d Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 16 May 2011 13:24:05 +0100 Subject: [PATCH] x86/tsc: Remove incorrect assertion from cstate_restore_tsc()... ..fix and move to write_tsc(). Signed-off-by: Keir Fraser --- xen/arch/x86/smpboot.c | 7 ++++++- xen/arch/x86/time.c | 2 -- xen/include/asm-x86/msr.h | 8 +++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index fddf85f2fe..deab8f7607 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -175,7 +175,12 @@ static void synchronize_tsc_slave(unsigned int slave) while ( atomic_read(&tsc_count) != ((i<<1)-1) ) cpu_relax(); rmb(); - write_tsc(tsc_value); + /* + * If a CPU has been physically hotplugged, we may as well write + * to its TSC in spite of X86_FEATURE_TSC_RELIABLE. The platform does + * not sync up a new CPU's TSC for us. + */ + __write_tsc(tsc_value); atomic_inc(&tsc_count); } } diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index e1223df1fd..282d3b7b59 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -686,8 +686,6 @@ void cstate_restore_tsc(void) if ( boot_cpu_has(X86_FEATURE_NONSTOP_TSC) ) return; - ASSERT(boot_cpu_has(X86_FEATURE_TSC_RELIABLE)); - write_tsc(stime2tsc(read_platform_stime())); } diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h index 09fa288081..3b4132f867 100644 --- a/xen/include/asm-x86/msr.h +++ b/xen/include/asm-x86/msr.h @@ -87,7 +87,13 @@ static inline int wrmsr_safe(unsigned int msr, uint64_t val) } while(0) #endif -#define write_tsc(val) wrmsrl(MSR_IA32_TSC, val) +#define __write_tsc(val) wrmsrl(MSR_IA32_TSC, val) +#define write_tsc(val) ({ \ + /* Reliable TSCs are in lockstep across all CPUs. We should \ + * never write to them. */ \ + ASSERT(!boot_cpu_has(X86_FEATURE_TSC_RELIABLE)); \ + __write_tsc(val); \ +}) #define write_rdtscp_aux(val) wrmsr(MSR_TSC_AUX, (val), 0) -- 2.30.2